package com.mobileares.midp.widgets.client.textbox2;

import com.google.gwt.user.client.ui.CheckBox;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-12-7
 * Time: 10:09:22
 * To change this template use File | Settings | File Templates.
 */
public class CheckBoxLabel extends BaseLabelText<Object, CheckBox> {
    private CheckBox tb = new CheckBox();

    public CheckBoxLabel(String label) {
        super(label);
        setLabelWidget(tb);
//        tb.setStyleName("textbox-input");
    }

    public Object getValue() {
        return tb.getValue();
    }

    public void setValue(Object ob) {
        Object oldValue = getValue();
        if (ob instanceof Boolean)
            tb.setValue(ob == null ? Boolean.FALSE : (Boolean) ob);
        else
            tb.setValue(ob == null ? Boolean.FALSE : ob.toString().equals("1"));
        changeValue(getValue(), oldValue);
    }

//    @Override
//    protected void fireErrorMessage() {
//        tb.removeStyleDependentName("focus");
//        tb.addStyleDependentName("error");
//
//    }
//
//    @Override
//    protected void fireFocus(FocusEvent event) {
//        tb.removeStyleDependentName("error");
//        tb.addStyleDependentName("focus");
//    }
//
//    @Override
//    protected void fireBlur(BlurEvent event) {
//        tb.removeStyleDependentName("focus");
//    }
}
